const Cart = {
  // 查询更新后的sql语句
  insertShopMessage(option) {
    return `INSERT into goods_cart(user_phone,good_id,good_name,good_price,good_des,good_src,good_num) VALUES(${option.tel},${option.good_id},'${option.shopName}','${option.price}','${option.good_describe}','${option.picture}',1) `
  },

  // 查询该用户的购物车数据
  selectShopMessage(option) {
    return `select * from goods_cart where user_phone= ${option.tel}`
  },

  //删除购物车指定商品信息
  delShopMessage(option) {
    return `delete from goods_cart where id=${option}`
  },

  // 查询用户的id
  selectUserId(option) {
    return `select user_id from user where user_phone= ${option.tel}`
  },

  // 获取订单号的id
  selectOrderId(option) {
    return `select id from ordernumber where ordernumber_id=${option}`
  },

  // 插入订单号数据库操作
  insertOrderNumber(option) {
    // 传过来的数据
    console.log(`mysql插入接收到的数据${option}`)
    return `insert into ordernumber(ordernumber_id,ordernumber_user_id,ordernumber_status) values(${option.shopId},${option.userId},0)`
  },

  // 插入订单号商品信息
  insertOrderFrom(option) {
    console.log(`数据`)
    console.log(option)
    let name = JSON.stringify(option.good_name)
    let price = JSON.stringify(option.good_price)
    let des = JSON.stringify(option.good_des)
    let src = JSON.stringify(option.good_src)
    let good_id = JSON.stringify(option.good_id)
    return `insert into orderfrom(orderfrom_ordernumber_id,orderfrom_name,orderfrom_price,orderfrom_number,orderfrom_des,orderfrom_src,orderfrom_list_id) values(${option.order_id},${name},${price},${option.good_num},${des},${src},${good_id})`
  },

  // 清空购物车数据
  delCartShopMes(option) {
    return `delete from goods_cart where id=${option}`
  },
}

exports = module.exports = Cart
